#include <stdio.h>
#include <vector>
#include <math.h>
using namespace std;

vector<int>allPrime;

bool isPrime(int n)
{
    //预剪枝
    if(n==2||n==3)
        return true;
    if(n%6!=1 && n%6!=5)
        return false;

    float n_sqrt=floor(sqrt(n)); //取整

    //大于5的质数一定和6的倍数相邻
    //因此素数要出现只可能出现在6x的相邻两侧。因此在5到sqrt(n)中每6个数只判断2个
    for(int i=5;i<=n_sqrt;i+=6)
    {
        if(n%(i)==0||n%(i+2)==0)
            return false;
    }
    return true;
}

bool candiv(int num,int divnum)
{
    return num%divnum==0;
}

int fatsum(int num,int nowsum)
{
    if(isPrime(num))
        return nowsum+num;
    for(int p:allPrime)
    {
        if(p>num/2)
            break;
        if(candiv(num,p))
            return fatsum(num/p,nowsum+p);
    }
    return nowsum;
}

int main()
{
    int num;
    scanf("%d",&num);
    for(int i=2;i<num/2;i++)
    {
        if(isPrime(i))
            allPrime.push_back(i);
    }
    printf("%d",fatsum(num,0));
}
